casting operator(类型转换运算符):在编程语言中,用于把一个值从一种数据类型转换为另一种数据类型的运算符或语法形式。常见于 C/C++(如 (int)x)、C#(如 (int)x)、Java(如 (int)x)等语言(不同语言的写法与规则可能不同)。
/ˈkæstɪŋ ˈɑːpəreɪtər/
I used a casting operator to convert the float to an int.
我用了类型转换运算符把浮点数转换成整数。
If you apply a casting operator to an object without checking its type, the program may throw an error at runtime.
如果你不先检查类型就对对象使用类型转换运算符,程序可能会在运行时抛出错误。
cast 原意有“投掷、铸造、塑形”的意思,在编程语境里引申为“把数据‘塑形’成另一种类型”,即“类型转换”。operator 来自拉丁语 operari(工作、操作),在计算机领域指“执行某种操作的符号或关键字”。合起来就是“执行类型转换的运算符”。
static_cast 等)。